package com.xuhuan.practice.config;

import com.xuhuan.practice.interceptors.LoginInterceptor;
import com.xuhuan.practice.properties.JWTProperties;
import com.xuhuan.practice.utils.SpringContextUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author: huan.xu
 * @create: 2024/6/10 21:54
 * @description:
 **/
@Configuration
public class WebConfig implements WebMvcConfigurer {

  @Autowired
  private LoginInterceptor loginInterceptor;

  @Override
  public void addInterceptors(InterceptorRegistry registry) {
    JWTProperties jwtProperties = SpringContextUtil.getBean(JWTProperties.class);
    registry.addInterceptor(loginInterceptor)
        .excludePathPatterns(jwtProperties.getExcludePathPatterns());
  }
}












